import os
os.environ["OPENAI_API_KEY"] = 'sk-e3c88c1501a944b3dc8898dd57cec623fa5bd7cd49d001ceeef7aeddd1094d'
os.environ["OPENAI_BASE_URL"] = 'https://a0ai-api.zijieapi.com/api/llm/'
os.environ["EMBEDDING_MODELEND"] = 'Doubao-embedding'
os.environ["LLM_MODELEND"] = 'Doubao-pro-32k'
os.environ['HUGGINGFACEHUB_API_TOKEN'] = 'hf_rugMWSUucWdxJhEAOzHUaRrepDqMlYNy'

# 导入聊天消息类模板
from langchain.prompts import (
    ChatPromptTemplate,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)

# 模板的构建
template = "你是一位专业顾问，负责为专注于{product}的公司起名。"
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "公司主打产品是{product_detail}。"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
prompt_template = ChatPromptTemplate.from_messages(
    [system_message_prompt, human_message_prompt]
)

# 格式化提示消息生成提示
prompt = prompt_template.format_prompt(
    product="鲜花装饰", product_detail="创新的鲜花设计。"
).to_messages()

# 下面调用模型，把提示消息传入模型，生成结果
from langchain_openai import ChatOpenAI

chat = ChatOpenAI(
    model=os.environ.get("LLM_MODELEND"),
)
result = chat.invoke(prompt)
print(result)